<template>
	<div id="main">
		<Header />
		<div id="content">
			<div class="movie_menu">
				<router-link tag="div" to="/movies/city" class="city_name">
				<!-- 在vuex中获取本地储存下的城市 -->
					<span>{{$store.state.city.nm}}</span><i class="iconfont icon-xiasanjiaoxing"></i>
				</router-link>
				<div class="hot_swtich">
					<router-link to="/movies/nowplaying" class="hot_item">正在热映</router-link>
					<router-link to="/movies/commingsoon" class="hot_item">即将上映</router-link>
				</div>
				<router-link tag="div" to="/movies/search" class="search_entry">
					<i class="iconfont icon-magnifier"></i>
				</router-link>
			</div>
			<!-- 路由懒加载 -->
			<keep-alive>
				<router-view />
			</keep-alive>
		</div>
		<tabBar></tabBar>

		<!-- 命名路由 详情页 这个detail是对应关系 -->
		<router-view name="detail"/>
		
	</div>
</template>

<script>
	import Header from '../../components/Header/Header.vue'
	import tabBar from '../../components/tabBar/tabBar.vue'
	import {
		messageBox
	} from '@/components/JS' //引入弹窗JS
	export default {
		data() {
			return {
				
			}
		},
		components: {
			Header,
			tabBar,
		},
		mounted() {
			//载入后 提示用户当前的位置
			setTimeout(() => {
				this.axios.get('/getLocation').then(res => {
					let code = res.data.code
					if(code === 0){
						let nm = res.data.data.nm
						let id = res.data.data.id
						if(this.$store.state.city.id == id) {return};
						messageBox({
							title: "定位",
							content: nm,
							cancel: "取消",
							ok: "切换定位",
							handleOk() {
								console.log("切换定位")
								window.localStorage.setItem('nowNm',nm)
								window.localStorage.setItem('nowId',id)
								window.location.reload();
							}
						})
					}
				})
			}, 3000);
			
		}
	}
</script>

<style scoped>
	#content .movie_menu {
		width: 100%;
		height: 45px;
		border-bottom: 1px solid #e6e6e6;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: white;
		z-index: 10;
	}

	.movie_menu .city_name {
		margin-left: 20px;
		height: 100%;
		line-height: 44px;
	}

	.movie_menu .city_name.router-link-active {
		color: #ef4238;
		border-bottom: 2px #ef4238 solid;
	}

	.movie_menu .hot_swtich {
		display: flex;
		height: 100%;
		line-height: 45px;
	}

	.movie_menu .hot_item {
		font-size: 15px;
		color: #666;
		width: 80px;
		text-align: center;
		margin: 0 12px;
		font-weight: 700;
	}

	.movie_menu .hot_item.router-link-active {
		color: #ef4238;
		border-bottom: 2px #ef4238 solid;
	}

	.movie_menu .search_entry {
		margin-right: 20px;
		height: 100%;
		line-height: 45px;
	}

	.movie_menu .search_entry.router-link-active {
		color: #ef4238;
		border-bottom: 2px #ef4238 solid;
	}

	.movie_menu .search_entry i {
		font-size: 24px;
		color: red;
	}
</style>
